package com.wlps.config;

import com.wlps.filter.CheckTokenFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *
 * </p>
 *
 * @author ZWYZY
 * @since 2020/8/1
 */
@Configuration
public class FilterConfig {
    @Autowired
    private CheckTokenFilter checkTokenFilter;
    @Bean
    public FilterRegistrationBean getFilterRegistrationBean() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        /**
             * 设置过滤器
             */
        filterRegistrationBean.setFilter(checkTokenFilter);
        /**
             * 拦截路径
             */
        filterRegistrationBean.addUrlPatterns("/api/user/login");
        /**
             * 设置名称
             */
        filterRegistrationBean.setName("myFilter");
        /**
            * 设置访问优先级 值越小越高
             */
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }
}
